<template>
  <div class="container">
    <div>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form ref="form" :model="form">
            <el-form-item label="选择日期：">
              <el-date-picker
                v-model="form.valueDay"
                type="date"
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="6">
          <el-form ref="form" :model="form">
            <el-form-item label="班组：">
              <el-select v-model="teamValue" placeholder>
                <el-option
                  v-for="item in teamList"
                  :key="item.CLIENT_NO"
                  :label="item.CLIENT_NAME"
                  :value="item.CLIENT_NO"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="6">
          <el-form ref="form" :model="form" style="float:left">
            <el-button size="mini" type="primary" @click="getlistdata">查 询</el-button>
            <el-button size="mini" type="success" @click="exportExcel">导 出</el-button>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <el-table :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)" highlight-current-row>
      <el-table-column prop="CLIENT_NAME" label="班组名称" align="center"></el-table-column>
            <el-table-column prop="NAME" label="人员姓名" align="center"></el-table-column>
            <el-table-column prop="APOINT" label="考勤得分" align="center"></el-table-column>
            <el-table-column prop="WORKCOUNT" label="作业遍数" align="center"></el-table-column>
            <el-table-column prop="CPOINT" label="作业遍数得分" align="center"></el-table-column>
            <el-table-column prop="WORKTIME" label="作业时长" align="center"></el-table-column>
            <el-table-column prop="TPOINT" label="作业时长得分" align="center"></el-table-column>
            <el-table-column prop="STAYALARM" label="报警次数" align="center"></el-table-column>
            <el-table-column prop="ALARMPOINT" label="报警扣分" align="center"></el-table-column>
            <el-table-column prop="POINT" label="总分" align="center"></el-table-column>
      <!-- <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-info" @click="handleEdit(scope.$index, scope.row)">详情</el-button>
        </template>
      </el-table-column>-->
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="tableData.length"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import '@/assets/css/common.css'
import { formatDate } from '@/common/js/date.js'
import export2Excel from '@/utils/exportExcel/index.js'
export default {
  data () {
    return {
      currentPage: 1, //初始页
      pageSize: 10,    //    每页的数据
      form: {
        radioData: '日',
        valueDay: formatDate(new Date(new Date() - 3600 * 1000 * 24), 'yyyy-MM-dd'),
        valueMonth: ''
      },
      teamList:[],
      teamValue:'',
      tableData: [],
      originalData: []
    }
  },
  created () {
    this.getTeamList()
    this.getlistdata()
  },
  methods: {
    async getTeamList () {
      const { data } = await this.$Http.get('DataListCompany/GetTeamListApi?ClientNo=' + localStorage.getItem('CLIENT_NO'))
      this.teamList = data
      this.teamList.unshift({"CLIENT_NO":localStorage.getItem('CLIENT_NO'),"CLIENT_NAME":"全部"})
      this.teamValue = localStorage.getItem('CLIENT_NO')
      // this.attendanceMonth.records.teamList = data
    },
    async getlistdata () {
      this.currentPage = 1;
      var url = 'Worker/GetPointInfo?ClientNo=' + this.teamValue + '&date=' + this.form.valueDay
      const { data } = await this.$Http.get(url)
      this.tableData = data
    },
    // 导出Excel
    exportExcel () {
      let excelName = '环卫工绩效评分统计'
      const tHeader = ['班组名称', '人员姓名', '考勤得分', '作业遍数', '作业遍数得分','作业时长', '作业时长得分', '报警次数', '报警扣分', '总分']
      const filterVal = ['CLIENT_NAME', 'NAME', 'APOINT', 'WORKCOUNT', 'CPOINT', 'WORKTIME', 'TPOINT', 'STAYALARM', 'ALARMPOINT', 'POINT']
      export2Excel(tHeader, filterVal, this.tableData, excelName)
    },
    //详情
    handleEdit (index, row) {
      //   this.idx = index;
      //   this.form = row;
      //   this.editVisible = true;
    },
    // 分页导航
    handlePageChange (currentPage) {
      this.currentPage = currentPage;
      // console.log(this.currentPage)
      // this.$set(this.query, 'pageIndex', val);
      // this.getData();
    },
    handleSizeChange (size) {
      this.pageSize = size;
      console.log(this.pageSize)
    }
  }
}
</script>
<style>
.content {
  overflow-y: scroll;
}
.el-col-6 {
  min-width: 400px;
  min-height: 50px;
}
.el-table th {
  height: 40px;
}
</style>